/*package com.utils.spring;

import static com.jayway.restassured.RestAssured.given;
import static org.junit.runners.MethodSorters.NAME_ASCENDING;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.ActiveProfiles;

import com.google.common.collect.Maps;
import com.jayway.restassured.http.ContentType;
import com.jayway.restassured.response.Header;
import com.jayway.restassured.response.Headers;
import com.jayway.restassured.response.Response;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
import com.kyhd.toutiao.controller.model.QuickLoginRequest;
import com.kyhd.toutiao.service.RedisService;
import com.kyhd.toutiao.service.UserLiveService;
import com.kyhd.toutiao.util.DateUtil;
import com.kyhd.toutiao.util.EncrypUtil;
import com.kyhd.toutiao.util.InitConst;

@ActiveProfiles("test")
@org.junit.FixMethodOrder(NAME_ASCENDING)
public class UserControllerTest extends AbstractApiIntegrationTest {
	
	@Autowired
	RedisService redisService;

    @Override
	@Before
    public void setUp() throws IOException {
        super.setUp();
    }

    @After
    public void tearDown() {
    	
    }
   
    protected Headers makeHeaders(Map<String, String> map) {
        List<Header> list = new ArrayList<Header>();

        for (String _key : map.keySet()) {
            Header header = new Header(_key, map.get(_key));
            list.add(header);
        }

        return new Headers(list);
    }

    

    protected void makeTest(String url, Headers headers, ContentType contentType, HttpStatus httpStatus, String content) {
        contentType = contentType == null ? ContentType.ANY : contentType;
        RequestSpecification req = given().contentType(contentType).headers(headers);

        ResponseSpecification res = req.expect().statusCode(httpStatus.value());
        if (StringUtils.isNotBlank(content)) {
            res.expect().content(Matchers.containsString(content));
        }
        res.when().get(url);
    }

    protected void makeTest(String url, Headers headers, ContentType contentType, HttpStatus httpStatus,
            String content, Map<String, String> pathParams) {
        contentType = contentType == null ? ContentType.ANY : contentType;
        RequestSpecification req = given().contentType(contentType).headers(headers).parameters(pathParams);

        ResponseSpecification res = req.expect().statusCode(httpStatus.value());
        if (StringUtils.isNotBlank(content)) {
            res.expect().content(Matchers.containsString(content));
        }
        res.when().get(url);
    }
    
    
    public void testOpenApp(){
//    	Response response = given().contentType(ContentType.JSON).body(request).when().post("/fdp/api/customer/newCustomer");
		
//       	OpenAppRequest request = new OpenAppRequest();
//    	request.setDeviceID("mz001");
//    	request.setChannelCode("tuia");
//    	request.setMobileModel("meizu");
    	this.redisService.setKey("65JslrAB", "QWTYYUIO");
    	System.out.println(this.redisService.getValue("uuid"));
    	Response response = given().contentType(ContentType.JSON).param("uuid", "65JslrAB")
    			.when().get("/tt/api/user/time");
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    
    
    public void testSetVerificationCode(){
//    	Response response = given().contentType(ContentType.JSON).body(request).when().post("/fdp/api/customer/newCustomer");
    	String phone = " ";
    	
    	Response response = given().param("phone", phone)
    			.when().get("/tt/api/user/setcode");
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    
    public void testGetVerificationCode(){
//    	Response response = given().contentType(ContentType.JSON).body(request).when().post("/fdp/api/customer/newCustomer");
    	long times = DateUtil.getMills(new Date(), null)/1000;
    	String phone = " ";
		try {
			phone = EncrypUtil.encrypt(phone, times+InitConst.YZM_KEY);
		} catch (Exception e) {
			e.printStackTrace();
		}
Map map = Maps.newHashMap();
    	Response response = given().param("phone", phone)
    			.param("times", times)
    			.param("map", map)
    			.when().get("/tt/api/user/getcode");
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    
    public void testLogin(){
//    	Response response = given().contentType(ContentType.JSON).body(request).when().post("/fdp/api/customer/newCustomer");
    	long times = DateUtil.getMills(new Date(), null)/1000;
		String phone = " ";
		try {
			phone = EncrypUtil.encrypt(phone, times+InitConst.YZM_KEY);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		String code = "061158";

    	Response response = null;
		try {
			response = given().param("phone", phone)
					.param("code", EncrypUtil.encrypt(code, times+InitConst.YZM_KEY))
					.param("deviceID", EncrypUtil.encrypt("mz001", times+InitConst.YZM_KEY))
					.param("channelCode", EncrypUtil.encrypt("tuia", times+InitConst.YZM_KEY))
					.param("mobileModel", EncrypUtil.encrypt("meizu", times+InitConst.YZM_KEY))
					.param("times", times)
					.when().post("/tt/api/user/login");
		} catch (Exception e) {
			e.printStackTrace();
		}
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    
    public void testGetUserInfo() throws Exception{
    	
    	String uuid = "vfOlXEol";
    	long times = DateUtil.getMills(new Date(), null)/1000;
    	
       	Map<String, String> params = Maps.newHashMap();
    	params.put("uuid", uuid);
    	params.put("times", times+"");
    	params.put("token", "54D8911B36838F7BB6479DFA0E5BC4C0");
    	
    	String sign = EncrypUtil.createSign("/tt/api/user/getuser", params, true);
    	Response response = given().param("uuid", uuid)
    			.param("times", times+"")
    			.param("sign", sign)
    			.when().get("/tt/api/user/getuser");
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    
    public void testUpdateImage(){
    	
    	String uuid = "9LxUm12q";
    	long times = 1523963220DateUtil.getMills(new Date(), null)/1000;
    	String sign = "AB5AD1ED6F09778678895A0323A02DFF";
    	String image = "D:\\LocoDown\\user\\20180311\\20160226075133.jpg";
    	Response response = given().param("uuid", uuid)
    			.param("times", times)
    			.param("sign", sign)
    			.multiPart("image", new File(image))
    			.when().post("/tt/api/user/updateimage");
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    
    public void testUpdateSex(){
//    	Response response = given().contentType(ContentType.JSON).body(request).when().post("/fdp/api/customer/newCustomer");
    	String uuid = "9LxUm12q";
    	long times = 1523963220DateUtil.getMills(new Date(), null)/1000;
    	String sign = "C925644DA01A0F92A04695D6B44C2378";
    	String token = "4020ABCC6D5876768242860F9C9B847B";
    	String data = "0";
		try {
			data = EncrypUtil.encryptByToken("2", token);
		} catch (Exception e) {
			e.printStackTrace();
		}
    	Response response = given().param("uuid", uuid)
    			.param("times", times)
    			.param("sign", sign)
    			.param("data", data)
    			.when().post("/tt/api/user/updatesex");
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    
    public void testUpdateNickName(){
//    	Response response = given().contentType(ContentType.JSON).body(request).when().post("/fdp/api/customer/newCustomer");
    	String uuid = "9LxUm12q";
    	long times = 1523963220DateUtil.getMills(new Date(), null)/1000;
    	String sign = "5237892E171B7D991E48D7BCDD68AE81";
    	String token = "4020ABCC6D5876768242860F9C9B847B";
    	String data = "呱";
		try {
			data = EncrypUtil.encryptByToken("呱呱叫", token);
		} catch (Exception e) {
			e.printStackTrace();
		}
    	Response response = given().param("uuid", uuid)
    			.param("times", times)
    			.param("sign", sign)
    			.param("data", data)
    			.when().post("/tt/api/user/updatenick");
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    
    public void testupdateBirthday(){
//    	Response response = given().contentType(ContentType.JSON).body(request).when().post("/fdp/api/customer/newCustomer");
       	String uuid = "9LxUm12q";
    	long times = 1523963220DateUtil.getMills(new Date(), null)/1000;
    	String sign = "0DAE735180D6E45461FC34FD6692B179";
    	String token = "4020ABCC6D5876768242860F9C9B847B";
    	String data = "00000000";
		try {
			data = EncrypUtil.encryptByToken("19901122", token);
		} catch (Exception e) {
			e.printStackTrace();
		}
    	Response response = given().param("uuid", uuid)
    			.param("times", times)
    			.param("sign", sign)
    			.param("data", data)
    			.when().post("/tt/api/user/updatebirthday");
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    
    public void testBindPhone(){
//    	Response response = given().contentType(ContentType.JSON).body(request).when().post("/fdp/api/customer/newCustomer");
       	String uuid = "9LxUm12q";
    	long times = 1523963220DateUtil.getMills(new Date(), null)/1000;
    	String sign = "2B138327DCB3EBE641387EE94C86C94F";
    	String token = "4020ABCC6D5876768242860F9C9B847B";
    	String data = "11000000000,123456";
		try {
			data = EncrypUtil.encryptByToken(" ,123456", token);
		} catch (Exception e) {
			e.printStackTrace();
		}
    	Response response = given().param("uuid", uuid)
    			.param("times", times)
    			.param("sign", sign)
    			.param("data", data)
    			.when().post("/tt/api/user/bindphone");
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    
    public void testQuitLogin() throws Exception{
//    	Response response = given().contentType(ContentType.JSON).body(request).when().post("/fdp/api/customer/newCustomer");
       	String uuid = "9LxUm12q";
    	long times = 1523963220DateUtil.getMills(new Date(), null)/1000;
    	String sign = "E39893377C727CBE4EF46F33DAD3B77E";
    	String token = "4020ABCC6D5876768242860F9C9B847B";
    	
    	Map<String, String> params = Maps.newHashMap();
    	params.put("uuid", uuid);
    	params.put("times", times+"");
    	params.put("token", token);
		.header("uuid", times)
		.header("times", times)
		.header("sign", EncrypUtil.createSign("/tt/api/user/quits", params, true))
    	
    	Response response = given().param("uuid", uuid)
    			.param("times", times)
    			.param("sign", sign)
    			.when().post("/tt/api/user/quit");
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    
    public void testWechatLogin(){
    
//    	Response response = given().contentType(ContentType.JSON).body(request).when().post("/fdp/api/customer/newCustomer");
    	QuickLoginRequest request = new QuickLoginRequest();
    	request.setTimes(System.currentTimeMillis()/1000);
    	
    	Response response = given().contentType(ContentType.JSON).body(request)
    			.when().post("/tt/api/user/welogin");
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    
    public void testGetCashList(){
    	Response response = given().contentType(ContentType.JSON)
    			.when().get("/tt/api/share/getcashlist");
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    
    public void testSetcode(){
//    	Response response = given().contentType(ContentType.JSON).body(request).when().post("/fdp/api/customer/newCustomer");
    	String phone = " ";
    	String data= "123456";
    	Response response = given().param("phone", phone)
    			.param("data", data)
    			.when().post("/tt/api/user/setcode");
    	System.out.println(response.prettyPrint());
    	Assert.assertEquals(200, response.getStatusCode());
    }
    
    @Autowired 
    UserLiveService userLiveService;
    
    public void testSetcod222e(){
    	
    }
   
   
}
*/